import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../components/Login/Login.vue'
import Home from '../components/home/Home.vue'
import Welcome from '../components/welcome'
import Users from '../components/user/users.vue'
import UsersDashboard from '../components/user/usersDashboard.vue'
import OrganizationDashboard from '../components/organization/organizationDashboard.vue'
import Flyliense from '../components/flyliense/flyliense.vue'
import Events from '../components/match/events.vue'
import Matchs from '../components/match/matchs.vue'
import Reporters from '../components/news/reporters.vue'
import Score from '../components/match/score.vue'
import News from '../components/news/news.vue'
import Group from '../components/permission/group.vue'
import Upermissions from '../components/permission/upermissions.vue'
import Sys from '../components/sys/sys.vue'
import Usern from '../components/user/usern.vue'
import OrganizationManger from '../components/organization/organizationManger.vue'
import Organizations from  '../components/organization/organizations.vue'
import Roles from '../components/permission/roles.vue'
import UserInfo from '../components/user/userInfo.vue'
import MyOrganization from '../components/organization/myOrganization.vue'
import AdUser from '../components/user/adUser'
import UnAdUser from '../components/user/unAdUser.vue'
import SchoolOrgnization from '../components/organization/schoolOrgnization.vue'
import PrintScorebyQR from '../components/match/printScorebyQR'
import AssociationOrgnization from '../components/organization/associationOrgnization.vue'
import PrintScoreByCom from '../components/match/printScoreByCom'
import ContextDashboard from '../components/news/contextDashboard.vue'
import RolesDashboard from '../components/permission/rolesDashboard'
import SysLog from '../components/sys/sysLog.vue'
import MatchsDashboard from '../components/match/matchsDashboard.vue'
import Index from '../views/Index.vue'
import IndexNews from '../components/Index/IndexNews.vue'
import IndexMatch from '../components/Index/IndexMatch'
import IndexLicense from '../components/Index/Indexlicense.vue'
import IndexSelectFlyTeam from '../components/Index/IndexSelectFlyTeam.vue'
import IndexSelectTeam from '../components/Index/IndexSelectTeam.vue'
import JoinMatch from '../components/match/joinMatch.vue'
import JoinExam from '../components/flyliense/joinExam.vue'
import ExamManger from '../components/flyliense/examManger.vue'
import IndexSeleteTrainTeam from '../components/Index/IndexSeleteTrainTeam.vue'
import Index_M from '../components/Index/index_m.vue'
import IndexNews_m from '../components/Index/indexNews_m.vue'
import IndexMatch_M from '../components/Index/indexMatch_m.vue'
import IndexSelectTeam_m from '../components/Index/IndexSelectTeam_m.vue'
import IndexSeleteTrainTeam_m from '../components/Index/IndexSeleteTrainTeam_m.vue'
import IndexSelectFlyTeam_M from '../components/Index/IndexSelectFlyTeam_m.vue'
import IndexLicense_m from '../components/Index/Indexlicense_m.vue'
import Login_m from '../components/Login/mLogin.vue'
import ChangePassword from '../components/user/changePassword.vue'
Vue.use(VueRouter)

  const routes = [
  
    // {path:'/' ,redirect:'/login'},
    {path:'/',redirect:'/index'},
    {path:'/index',component:Index},
  {path:'/login',component:Login },

 
  {path:'/indexNews',component:IndexNews},
  {path:'/indexlicense',component:IndexLicense},
  {path:'/indexSelectFlyTeam',component:IndexSelectFlyTeam},
  {path:'/indexSelectTeam',component:IndexSelectTeam},
  {path:'/indexMatch',component:IndexMatch},
  {path:'/indexSeleteTrainTeam',component:IndexSeleteTrainTeam},
  
  //移动版
  {path:'/login_m',component:Login_m},
  {path:'/index_m',component:Index_M },
  {path:'/indexNews_m',component:IndexNews_m },
  {path:'/indexMatch_M',component:IndexMatch_M },
  {path:'/indexSelectTeam_m',component:IndexSelectTeam_m},
  {path:'/indexSeleteTrainTeam_m',component:IndexSeleteTrainTeam_m},
  {path:'/indexSelectFlyTeam_M',component:IndexSelectFlyTeam_M},
,
  {path:'/indexLicense_m',component:IndexLicense_m},
  //后台界面
  {path:'/home',
  component:Home ,
  redirect:'/welcome',
  children:[
    {path:'/welcome',component:Welcome},
    
    {path:'/changePassword',component:ChangePassword},
    {path:'/usersDashboard',component:UsersDashboard},//会员总览
    {path:'/member',component:Users},//会员管理
    {path:'/usern',component:Usern},//非会员管理
    {path:'/adUser',component:AdUser},//成年人管理
    {path:'/unAdUser',component:UnAdUser},//未成年人管理
    {path:'/userInfo',component:UserInfo},//我的个人
    {path:'/organizations',component:Organizations},//单位管理
    {path:'/organizationManger',component:OrganizationManger},//组织机构管理
    {path:'/schoolOrgnization',component:SchoolOrgnization},//学校管理
    {path:'/associationOrgnization',component:AssociationOrgnization},//协会管理
    {path:'/organizationDashboard',component:OrganizationDashboard},//单位总览
    {path:'/myOrganization',component:MyOrganization},//我的单位
    {path:'/flyliense',component:Flyliense},
    {path:'/events',component:Events},
    {path:'/matchs',component:Matchs
  },//赛事管理
  {path:'/matchsDashboard',component:MatchsDashboard},
    {path:'/reporters',component:Reporters},
    //成绩管理
    {path:'/joinMatch',component:JoinMatch},//赛事报名
    {path:'/score',component:Score  },
    {path:'/printScorebyQR',component:PrintScorebyQR},//扫码打分
    {path:'/printScoreByCom',componment:PrintScoreByCom},//批量打分
    {path:'/news',component:News},
    {path:'/contextDashboard',component:ContextDashboard},
    {path:'/group',component:Group},//组管理
    {path:'/upermissions',component:Upermissions},//权限管理
    {path:'/sys',component:Sys},
    {path:'/rolesDashboard',component:RolesDashboard},
    {path:'/roles',component:Roles},//角色管理 
    {path:'/sysLog',component:SysLog},
    {path:'/myOrganization',component:MyOrganization},
    {path:'/joinExam',component:JoinExam},
    {path:'/examManger',component:ExamManger},

  ]},
]

const router = new VueRouter({
  routes
})

//挂载一个路由导航守卫
//to将要访问的路径，from 从哪个路径跳转而来
//next是一个函数，表示放行
router.beforeEach((to,from,next) => {
  if(to.path==='/index')return next()
if(to.path==='/login')return next()
//获取token
const tokenStr=window.sessionStorage.getItem('token')
// if(!tokenStr) return next('/login')//这里记得改成login
next()
})




export default router
